package it.unibo.iss.domotica;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

public class UsrcmdActivitySupport extends Activity {
	
	protected boolean verbose = false;
	protected TextView output;
	protected int nm = 1;
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//Creazione thread di simulazione local job
		//workerThread = new CustomThread(myHandler);
	}

	protected void onStart() {
		super.onStart();
		traceMsg("onStart ... " + activityInfo());
	}

	protected void onResume() {
		super.onResume();
		traceMsg("onResume ... " + activityInfo());
		//Attivazione thread di simulazione job
		//workerThread.start();
	}

	protected void onPause() {
		super.onPause();
		traceMsg("onPause ... " + activityInfo());
	}

	protected void onRestart() {
		super.onRestart();
		traceMsg("onRestart ... " + activityInfo());
	}

	protected void onStop() {
		super.onStop();
		traceMsg("onStop ... " + activityInfo());
	}

	protected void onDestroy() {
		super.onDestroy();
		traceMsg("onDestroy ... " + activityInfo());
	}

	protected String activityInfo() {
		return this.getLocalClassName() + " | taskId=" + this.getTaskId();
	}
			
	protected void showMsgToast(String msg) {
		Toast.makeText(UsrcmdActivitySupport.this, msg, Toast.LENGTH_SHORT).show();
	} 
	
	protected void traceMsg(String msg) {
		if (verbose)
			println(msg);
	}
	
	protected void println(String msg) {
		if(output == null)
			output = (TextView) findViewById(R.id.output);
		
		if(output != null)
			output.append(nm++ + " > " + msg + "\n");
	}
}
